/// @file sensorplot.h
/// @brief Implementation of the sensorPlot class
/// @date 02/02/2010
/// @author Cédric Bardet, Reds, Heig-vd
#ifndef SENSORPLOT_H
#define SENSORPLOT_H

#include <QtGui/QDialog>
#include <qwt_plot.h>
#include <qwt_plot_curve.h>
#include "OakSensorVisual.h"
#include <qtimer.h>
#include "serializer.h"
#include "neuralnetwork.h"

/// size of array for the values xyz
#define nbr 50

#define maxCommands 6
#define maxSamples 10

namespace Ui {
    class sensorPlot;
}


/// This class manages the graph accelerometer window
class sensorPlot : public QDialog {
    Q_OBJECT
    Q_DISABLE_COPY(sensorPlot)



public:
  /// This class manages the Data of the time x y and z.
  class graphData{
   public:
    double time[nbr];
    double axemax[nbr];
    double x[nbr];
    double y[nbr];
    double z[nbr];
    }*gData;
     /// Constructor
     sensorPlot(QWidget *parent = 0);
     /// Destructor
     ~sensorPlot();
         int     exec(const QString& sensorPlot);

       graphData* init(bool newone);


signals:
       /// signal printAction connect with Analyser "onPrintAction"
     void printAction(sensorPlot::graphData *gData, bool print);

protected:
    virtual void changeEvent(QEvent *e);

private:
    /// main graphical element
    Ui::sensorPlot *m_ui;
            /// graph element
            QwtPlot *myPlot;
            /// curve X
            QwtPlotCurve *curve1;
            /// curve Y
            QwtPlotCurve *curve2;
            /// curve Z
            QwtPlotCurve *curve3;
            /// curve for graph initialisation: not visible
            QwtPlotCurve *curveinit;

            // number of current command and sample
            int nbCurrentCommand;
            int nbCurrentSample;

            Serializer *ser;

            NeuralNetwork _network;

            bool runNetwork(double* outputs);

QString m_sensorPlot;

QTimer m_Timer;

private slots:
    /// button stop
    void on_pushButton_7_clicked();
    void on_pushButton_6_clicked();
    void on_pushButton_4_clicked();
    /// button run
    void on_pushButton_3_clicked();
    /// buuton latest 100
    void on_pushButton_2_clicked();
    /// button close
    void on_pushButton_clicked();
    /// button saveSample
    void on_pushButton_5_clicked();

public slots:

    /// Called every tick of the timer
    void    running();



};


#endif // SENSORPLOT_H
